
import time

class TimeMgr:
    def __init__(self):
        self.__fpsCounter = 0
        self.__lastTime = 0
        self.__fps = 0
    def init(self):
        self.__fpsCounter = 0
        self.__lastTime = time.time()
        self.__fps = 0
    def update(self):
        now = time.time()
        # Check if a second has passed
        elapsed = now - self.__lastTime
        if elapsed >= 1.0:
            self.__fps = self.__fpsCounter + 1
            self.__fpsCounter = 0
            self.__lastTime = now - (elapsed - 1.0)
        else:
            self.__fpsCounter += 1
    def getFPS(self):
        return self.__fps
    def getTime(self):
        return time.time()
